package com.bjtu.literatureclient.controller.book;

import com.bjtu.literatureclient.service.book.BookService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/book")
public class BookController {
	
	@Autowired
	BookService bookService;
	
	@SuppressWarnings("unchecked")
	@RequestMapping(method = RequestMethod.POST)
	public String get(HttpServletRequest request){
		String type=request.getParameter("type");
		List<?> booklist = bookService.query(type);
		Gson gson = new Gson();
	    return gson.toJson(booklist);
	}
	
	
}
